#include <iostream>
using namespace std;

void Bubble(int a[],int N)
{
    int temp = 0;
    for (int i = N -1 ; i > 0; i--)
    {
        for (int j = 0; j < i; j++)
        {
            if (a[j] > a[j + 1])
            {
                temp = a[j];
                a[j] = a[j + 1];
                a[j + 1] = temp;
            }

        }
    }
    for(int t = 0; t < N ; t++)
    {
        cout << a[t] <<endl;
    }
    cout << endl;
}

void choose(int a[],int N)
{
    int min = 0, temp = 0;
    for (int i = 0;i < N ; i++)
    {
        min = i;
        for (int j = i + 1 ; j < N ; j++)
        {
            if (a[j]<a[min])
            {
                min = j;
            }
        }
        if (min != i)
        {
            temp = a[i];
            a[i] = a[min];
            a[min] = temp;
        }
    }
    for(int t = 0; t < N ; t++)
    {
        cout << a[t] <<endl;
    }
    cout << endl;
}

void insert(int a[],int N)
{
    int temp = 0;
    for(int i =1 ; i < N;i++)
    {   
        int j;
        temp = a[i];
        for(j = i;j>1&&a[j-1]>temp;j--)
        {
            a[j] = a[j-1];
        }
        a[j] = temp;
    }
    for(int t = 0; t < N ; t++)
    {
        cout << a[t] <<endl;
    }
}


int main()
{
    int a[5] = { 7, 8, 3, 1, 5 };
    int b[5] = { 17, 25, 10, 15, 5 };
    int c[5] = {2, 8, 15, 60, 24};
    int N = sizeof(a) / sizeof(a[0]);
    int n = sizeof(b) / sizeof(b[0]);
    int M = sizeof(c) / sizeof(c[0]);
    Bubble(a,N);
    choose(b,n);
    insert(c,M);

}